<!--- 
LICENSE INFORMATION:

Copyright 2007, Hem Talreja
 
Licensed under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance with the License. 

You may obtain a copy of the License at 

	http://www.apache.org/licenses/LICENSE-2.0 
	
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied. See the License for the 
specific language governing permissions and limitations under the License.

VERSION INFORMATION:	(0.1)

 --->

<!--- 
	EXCEPTION FILE CONTENT SAMPLE
	
	<cfset stcDataTypes = StructNew() />
	<cfset stcDataTypes.VARCHAR = "CF_SQL_VARCHAR" />
	<cfset stcDataTypes.NVARCHAR = "CF_SQL_VARCHAR" />
	<cfwddx input="#stcDataTypes#" output="strWddx" action="cfml2wddx" />
 --->

<cfcomponent output="false" hint="component to map database datatypes to cfqueryparam">
	
	<!--- in this scope to enable output of all preset datatypes --->	
	<cfset this.stcDataTypes = StructNew() />
	<cfset this.stcDataTypes["INT"] = "CF_SQL_INTEGER" />   
	<cfset this.stcDataTypes["NVARCHAR"] = "CF_SQL_VARCHAR" />
	
	
	<cffunction name="init" access="public" returntype="dbDataTypes" output="false">
		<cfargument name="DataTypeDefFile" type="string" required="true" />
		
		<cfset var strFileContents = "" />
		
		<cfif FileExists(Arguments.DataTypeDefFile)>
		
			<cffile action="read" file="#Arguments.DataTypeDefFile#" variable="strFileContents" />
			
			<cfif IsWddx(strFileContents)>
				<cfwddx action="wddx2cfml" input="#strFileContents#" output="this.stcDataTypes" />
			</cfif>
			
		</cfif>
		
		<cfreturn this />
	</cffunction>



	<cffunction name="DefinationExists" access="package" returntype="boolean" output="false">
		<cfargument name="dataType" type="string" required="true" />
		
		<cfif IsDefined("this.stcDataTypes.#Arguments.dataType#")>
			<cfreturn true />
		</cfif>
			
		<cfreturn false />	
	</cffunction>
	

	
	<cffunction name="getCFQueryDataType" access="public" returntype="string" output="false">
		<cfargument name="dataType" type="string" required="true" />
		
		<cfset var strReturnDataType = "CF_SQL_" & UCASE(Arguments.DataType) />
		
		<cfif DefinationExists(Arguments.DataType)>
			<cfset strReturnDataType = this.stcDataTypes[Arguments.DataType] />		
		</cfif>
		
		<cfreturn strReturnDataType />
	</cffunction>



</cfcomponent>